package com.xing.lei.happy.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class NumberUtils extends org.apache.commons.lang.math.NumberUtils {
	private static final Object DF_LOCK = new Object();
	private static  DecimalFormat df;

	private static DecimalFormat getDecimalFormat() {
        if (df == null) {
            synchronized (DF_LOCK) {
                if (df == null) {
                    df = new DecimalFormat("#.######");
                }
            }
        }
		return df;
	}

	public static boolean equals(Short o1, Short o2) {
		if (o1 == null && o2 == null) {
			return true;
		}
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.shortValue() == o2;
	}

	public static boolean notEquals(Short o1, Short o2) {
		return !equals(o1, o2);
	}

	public static boolean hasEquals(Short orig, Short... dests) {
		if (orig == null && dests == null) {
			return true;
		}
		if (ArrayUtils.isEmpty(dests)) {
			return false;
		}
		for (Short dest : dests) {
			if (equals(orig, dest)) {
				return true;
			}
		}
		return false;
	}

	public static boolean notHasEquals(Short orig, Short... dests) {
		return !hasEquals(orig, dests);
	}

	public static boolean greater(Short o1, Short o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.shortValue() > o2;
	}

	public static boolean notGreater(Short o1, Short o2) {
		return !greater(o1, o2);
	}

	public static boolean greaterOrEquals(Short o1, Short o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.shortValue() >= o2;
	}

	public static boolean notGreaterOrEquals(Short o1, Short o2) {
		return !greaterOrEquals(o1, o2);
	}

	public static boolean less(Short o1, Short o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.shortValue() < o2;
	}

	public static boolean notLess(Short o1, Short o2) {
		return !less(o1, o2);
	}

	public static boolean lessOrEquals(Short o1, Short o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.shortValue() <= o2;
	}

	public static boolean notLessOrEquals(Short o1, Short o2) {
		return !lessOrEquals(o1, o2);
	}

	public static Short limit(Short o, Short min, Short max, Short defaultValue) {
		if (greater(min, max)) {
			Short temp = min;
			min = max;
			max = temp;
		}
		if (o == null) {
			return filter(defaultValue, min, max);
		} else if (less(o, min)) {
			return filter(defaultValue, min);
		} else if (greater(o, max)) {
			return filter(defaultValue, max);
		} else {
			return o;
		}
	}

	public static Short limit(Short o, Short min, Short max) {
		return limit(o, min, max, null);
	}

	public static Short limit(Short o, Short minmax) {
		return limit(o, minmax, minmax, null);
	}

	public static Short max(Short... os) {
		if (os == null) {
			return null;
		}
		Short result = null;
		for (Short o : os) {
			if (result == null || greater(o, result)) {
				result = o;
			}
		}
		return result;
	}


	public static Short min(Short... os) {
		if (os == null) {
			return null;
		}
		Short result = null;
		for (Short o : os) {
			if (result == null || less(o, result)) {
				result = o;
			}
		}
		return result;
	}






	public static Short subtract(Short o1, Short o2) {
		if (ObjectUtils.hasBlank(o1, o2)) {
			return null;
		}
		return (short)(o1-o2);
	}


	public static Short divide(Short o1, Short o2) {
		if (ObjectUtils.hasBlank(o1, o2) || o2 == 0) {
			return null;
		}
		return (short)(o1 / o2);
	}

	public static Short filter(Short... os) {
		return ObjectUtils.filter(os);
	}

	public static Integer abs(Integer o) {
		return o == null ? null : Math.abs(o);
	}

	public static boolean equals(Integer o1, Integer o2) {
		if (o1 == null && o2 == null) {
			return true;
		}
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.intValue() == o2;
	}

	public static boolean notEquals(Integer o1, Integer o2) {
		return !equals(o1, o2);
	}

	public static boolean hasEquals(Integer orig, Integer... dests) {
		if (orig == null && dests == null) {
			return true;
		}
		if (ArrayUtils.isEmpty(dests)) {
			return false;
		}
		for (Integer dest : dests) {
			if (equals(orig, dest)) {
				return true;
			}
		}
		return false;
	}

	public static boolean notHasEquals(Integer orig, Integer... dests) {
		return !hasEquals(orig, dests);
	}

	public static boolean greater(Integer o1, Integer o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.intValue() > o2;
	}

	public static boolean notGreater(Integer o1, Integer o2) {
		return !greater(o1, o2);
	}

	public static boolean greaterOrEquals(Integer o1, Integer o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.intValue() >= o2;
	}

	public static boolean notGreaterOrEquals(Integer o1, Integer o2) {
		return !greaterOrEquals(o1, o2);
	}

	public static boolean less(Integer o1, Integer o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.intValue() < o2;
	}

	public static boolean notLess(Integer o1, Integer o2) {
		return !less(o1, o2);
	}

	public static boolean lessOrEquals(Integer o1, Integer o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.intValue() <= o2;
	}

	public static boolean notLessOrEquals(Integer o1, Integer o2) {
		return !lessOrEquals(o1, o2);
	}

	public static Integer limit(Integer o, Integer min, Integer max,
			Integer defaultValue) {
		if (greater(min, max)) {
			Integer temp = min;
			min = max;
			max = temp;
		}
		if (o == null) {
			return filter(defaultValue, min, max);
		} else if (less(o, min)) {
			return filter(defaultValue, min);
		} else if (greater(o, max)) {
			return filter(defaultValue, max);
		} else {
			return o;
		}
	}

	public static Integer limit(Integer o, Integer min, Integer max) {
		return limit(o, min, max, null);
	}

	public static Integer limit(Integer o, Integer minmax) {
		return limit(o, minmax, minmax, null);
	}

	public static Integer max(Integer... os) {
		if (os == null) {
			return null;
		}
		Integer result = null;
		for (Integer o : os) {
			if (result == null || greater(o, result)) {
				result = o;
			}
		}
		return result;
	}


	public static Integer min(Integer... os) {
		if (os == null) {
			return null;
		}
		Integer result = null;
		for (Integer o : os) {
			if (result == null || less(o, result)) {
				result = o;
			}
		}
		return result;
	}

	public static Integer sum(Integer... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Integer result = null;
		for (Integer o : os) {
			if (o != null) {
				if (result == null) {
					result = 0;
				}
				result += o;
			}
		}
		return result;
	}

	public static Integer add(Integer... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Integer result = 0;
		for (Integer o : os) {
			if (o == null) {
				return null;
			}
			result += o;
		}
		return result;
	}

	public static Integer subtract(Integer o1, Integer o2) {
		if (ObjectUtils.hasBlank(o1, o2)) {
			return null;
		}
		return o1 - o2;
	}

	public static Integer multiply(Integer... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Integer result = 1;
		for (Integer o : os) {
			if (o == null) {
				return null;
			}
			result *= o;
		}
		return result;
	}

	public static Integer divide(Integer o1, Integer o2) {
		if (ObjectUtils.hasBlank(o1, o2) || o2 == 0) {
			return null;
		}
		return o1 / o2;
	}

	public static Integer filter(Integer... os) {
		return ObjectUtils.filter(os);
	}

	public static Long abs(Long o) {
		return o == null ? null : Math.abs(o);
	}

	public static boolean equals(Long o1, Long o2) {
		if (o1 == null && o2 == null) {
			return true;
		}
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.longValue() == o2;
	}

	public static boolean notEquals(Long o1, Long o2) {
		return !equals(o1, o2);
	}

	public static boolean hasEquals(Long orig, Long... dests) {
		if (orig == null && dests == null) {
			return true;
		}
		if (ArrayUtils.isEmpty(dests)) {
			return false;
		}
		for (Long dest : dests) {
			if (equals(orig, dest)) {
				return true;
			}
		}
		return false;
	}

	public static boolean notHasEquals(Long orig, Long... dests) {
		return !hasEquals(orig, dests);
	}

	public static boolean greater(Long o1, Long o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.longValue() > o2;
	}

	public static boolean notGreater(Long o1, Long o2) {
		return !greater(o1, o2);
	}

	public static boolean greaterOrEquals(Long o1, Long o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.longValue() >= o2;
	}

	public static boolean notGreaterOrEquals(Long o1, Long o2) {
		return !greaterOrEquals(o1, o2);
	}

	public static boolean less(Long o1, Long o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.longValue() < o2;
	}

	public static boolean notLess(Long o1, Long o2) {
		return !less(o1, o2);
	}

	public static boolean lessOrEquals(Long o1, Long o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.longValue() <= o2;
	}

	public static boolean notLessOrEquals(Long o1, Long o2) {
		return !lessOrEquals(o1, o2);
	}

	public static Long limit(Long o, Long min, Long max, Long defaultValue) {
		if (greater(min, max)) {
			Long temp = min;
			min = max;
			max = temp;
		}
		if (o == null) {
			return filter(defaultValue, min, max);
		} else if (less(o, min)) {
			return filter(defaultValue, min);
		} else if (greater(o, max)) {
			return filter(defaultValue, max);
		} else {
			return o;
		}
	}

	public static Long limit(Long o, Long min, Long max) {
		return limit(o, min, max, null);
	}

	public static Long limit(Long o, Long minmax) {
		return limit(o, minmax, minmax, null);
	}

	public static Long max(Long... os) {
		if (os == null) {
			return null;
		}
		Long result = null;
		for (Long o : os) {
			if (result == null || greater(o, result)) {
				result = o;
			}
		}
		return result;
	}


	public static Long min(Long... os) {
		if (os == null) {
			return null;
		}
		Long result = null;
		for (Long o : os) {
			if (result == null || less(o, result)) {
				result = o;
			}
		}
		return result;
	}

	public static Long sum(Long... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Long result = null;
		for (Long o : os) {
			if (o != null) {
				if (result == null) {
					result = 0L;
				}
				result += o;
			}
		}
		return result;
	}

	public static Long add(Long... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Long result = 0L;
		for (Long o : os) {
			if (o == null) {
				return null;
			}
			result += o;
		}
		return result;
	}

	public static Long subtract(Long o1, Long o2) {
		if (ObjectUtils.hasBlank(o1, o2)) {
			return null;
		}
		return o1 - o2;
	}

	public static Long multiply(Long... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Long result = 1L;
		for (Long o : os) {
			if (o == null) {
				return null;
			}
			result *= o;
		}
		return result;
	}

	public static Long divide(Long o1, Long o2) {
		if (ObjectUtils.hasBlank(o1, o2) || o2 == 0) {
			return null;
		}
		return o1 / o2;
	}

	public static Long filter(Long... os) {
		return ObjectUtils.filter(os);
	}

	public static Float abs(Float o) {
		return o == null ? null : Math.abs(o);
	}

	public static boolean equals(Float o1, Float o2) {
		if (o1 == null && o2 == null) {
			return true;
		}
		if (o1 == null || o2 == null) {
			return false;
		}
		return new BigDecimal(o1).compareTo(new BigDecimal(o2)) == 0;
	}

	public static boolean notEquals(Float o1, Float o2) {
		return !equals(o1, o2);
	}

	public static boolean hasEquals(Float orig, Float... dests) {
		if (orig == null && dests == null) {
			return true;
		}
		if (ArrayUtils.isEmpty(dests)) {
			return false;
		}
		for (Float dest : dests) {
			if (equals(orig, dest)) {
				return true;
			}
		}
		return false;
	}

	public static boolean notHasEquals(Float orig, Float... dests) {
		return !hasEquals(orig, dests);
	}

	public static boolean greater(Float o1, Float o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.floatValue() > o2;
	}

	public static boolean notGreater(Float o1, Float o2) {
		return !greater(o1, o2);
	}

	public static boolean greaterOrEquals(Float o1, Float o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.floatValue() >= o2;
	}

	public static boolean notGreaterOrEquals(Float o1, Float o2) {
		return !greaterOrEquals(o1, o2);
	}

	public static boolean less(Float o1, Float o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.floatValue() < o2;
	}

	public static boolean notLess(Float o1, Float o2) {
		return !less(o1, o2);
	}

	public static boolean lessOrEquals(Float o1, Float o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.floatValue() <= o2;
	}

	public static boolean notLessOrEquals(Float o1, Float o2) {
		return !lessOrEquals(o1, o2);
	}

	public static Float limit(Float o, Float min, Float max, Float defaultValue) {
		if (greater(min, max)) {
			Float temp = min;
			min = max;
			max = temp;
		}
		if (o == null) {
			return filter(defaultValue, min, max);
		} else if (less(o, min)) {
			return filter(defaultValue, min);
		} else if (greater(o, max)) {
			return filter(defaultValue, max);
		} else {
			return o;
		}
	}

	public static Float limit(Float o, Float min, Float max) {
		return limit(o, min, max, null);
	}

	public static Float limit(Float o, Float minmax) {
		return limit(o, minmax, minmax, null);
	}

	public static Float max(Float... os) {
		if (os == null) {
			return null;
		}
		Float result = null;
		for (Float o : os) {
			if (result == null || greater(o, result)) {
				result = o;
			}
		}
		return result;
	}


	public static Float min(Float... os) {
		if (os == null) {
			return null;
		}
		Float result = null;
		for (Float o : os) {
			if (result == null || less(o, result)) {
				result = o;
			}
		}
		return result;
	}


	public static Float sum(Float... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Float result = null;
		for (Float o : os) {
			if (o != null) {
				if (result == null) {
					result = 0F;
				}
				result += o;
			}
		}
		return result;
	}

	public static Float add(Float... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Float result = 0F;
		for (Float o : os) {
			if (o == null) {
				return null;
			}
			result += o;
		}
		return result;
	}

	public static Float subtract(Float o1, Float o2) {
		if (ObjectUtils.hasBlank(o1, o2)) {
			return null;
		}
		return BigDecimal.valueOf(o1).subtract(BigDecimal.valueOf(o2)).floatValue();
	}

	public static Float multiply(Float... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Float result = 1F;
		for (Float o : os) {
			if (o == null) {
				return null;
			}
			result *= o;
		}
		return result;
	}

	public static Float divide(Float o1, Float o2) {
		if (ObjectUtils.hasBlank(o1, o2) || o2 == 0) {
			return null;
		}
		return BigDecimal.valueOf(o1).divide(BigDecimal.valueOf(o2)).floatValue();
	}

	public static Float filter(Float... os) {
		return ObjectUtils.filter(os);
	}

	public static Double abs(Double o) {
		return o == null ? null : Math.abs(o);
	}

	public static boolean equals(Double o1, Double o2) {
		if (o1 == null && o2 == null) {
			return true;
		}
		if (o1 == null || o2 == null) {
			return false;
		}
		return BigDecimal.valueOf(o1).compareTo(BigDecimal.valueOf(o2)) == 0;
	}

	public static boolean notEquals(Double o1, Double o2) {
		return !equals(o1, o2);
	}

	public static boolean hasEquals(Double orig, Double... dests) {
		if (orig == null && dests == null) {
			return true;
		}
		if (ArrayUtils.isEmpty(dests)) {
			return false;
		}
		for (Double dest : dests) {
			if (equals(orig, dest)) {
				return true;
			}
		}
		return false;
	}

	public static boolean notHasEquals(Double orig, Double... dests) {
		return !hasEquals(orig, dests);
	}

	public static boolean greater(Double o1, Double o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.doubleValue() > o2;
	}

	public static boolean notGreater(Double o1, Double o2) {
		return !greater(o1, o2);
	}

	public static boolean greaterOrEquals(Double o1, Double o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.doubleValue() >= o2;
	}

	public static boolean notGreaterOrEquals(Double o1, Double o2) {
		return !greaterOrEquals(o1, o2);
	}

	public static boolean less(Double o1, Double o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.doubleValue() < o2;
	}

	public static boolean notLess(Double o1, Double o2) {
		return !less(o1, o2);
	}

	public static boolean lessOrEquals(Double o1, Double o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.doubleValue() <= o2;
	}

	public static boolean notLessOrEquals(Double o1, Double o2) {
		return !lessOrEquals(o1, o2);
	}

	public static Double limit(Double o, Double min, Double max,
			Double defaultValue) {
		if (greater(min, max)) {
			Double temp = min;
			min = max;
			max = temp;
		}
		if (o == null) {
			return filter(defaultValue, min, max);
		} else if (less(o, min)) {
			return filter(defaultValue, min);
		} else if (greater(o, max)) {
			return filter(defaultValue, max);
		} else {
			return o;
		}
	}

	public static Double limit(Double o, Double min, Double max) {
		return limit(o, min, max, null);
	}

	public static Double limit(Double o, Double minmax) {
		return limit(o, minmax, minmax, null);
	}

	public static Double max(Double... os) {
		if (os == null) {
			return null;
		}
		Double result = null;
		for (Double o : os) {
			if (result == null || greater(o, result)) {
				result = o;
			}
		}
		return result;
	}


	public static Double min(Double... os) {
		if (os == null) {
			return null;
		}
		Double result = null;
		for (Double o : os) {
			if (result == null || less(o, result)) {
				result = o;
			}
		}
		return result;
	}


	public static Double sum(Double... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Double result = null;
		for (Double o : os) {
			if (o != null) {
				if (result == null) {
					result = 0D;
				}
				result += o;
			}
		}
		return result;
	}

	public static Double add(Double... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Double result = 0D;
		for (Double o : os) {
			if (o == null) {
				return null;
			}
			result += o;
		}
		return result;
	}

	public static Double subtract(Double o1, Double o2) {
		if (ObjectUtils.hasBlank(o1, o2)) {
			return null;
		}
		return o1 - o2;
	}

	public static Double multiply(Double... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Double result = 1D;
		for (Double o : os) {
			if (o == null) {
				return null;
			}
			result *= o;
		}
		return result;
	}

	public static Double divide(Double o1, Double o2) {
		if (ObjectUtils.hasBlank(o1, o2) || o2 == 0) {
			return null;
		}
		return o1 / o2;
	}

	public static Double filter(Double... os) {
		return ObjectUtils.filter(os);
	}

	public static boolean equals(BigDecimal o1, BigDecimal o2) {
		if (o1 == null && o2 == null) {
			return true;
		}
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.compareTo(o2) == 0;
	}

	public static boolean notEquals(BigDecimal o1, BigDecimal o2) {
		return !equals(o1, o2);
	}

	public static boolean hasEquals(BigDecimal orig, BigDecimal... dests) {
		if (orig == null && dests == null) {
			return true;
		}
		if (ArrayUtils.isEmpty(dests)) {
			return false;
		}
		for (BigDecimal dest : dests) {
			if (equals(orig, dest)) {
				return true;
			}
		}
		return false;
	}

	public static boolean notHasEquals(BigDecimal orig, BigDecimal... dests) {
		return !hasEquals(orig, dests);
	}

	public static boolean greater(BigDecimal o1, BigDecimal o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.doubleValue() > o2.doubleValue();
	}

	public static boolean notGreater(BigDecimal o1, BigDecimal o2) {
		return !greater(o1, o2);
	}

	public static boolean greaterOrEquals(BigDecimal o1, BigDecimal o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.doubleValue() >= o2.doubleValue();
	}

	public static boolean notGreaterOrEquals(BigDecimal o1, BigDecimal o2) {
		return !greaterOrEquals(o1, o2);
	}

	public static boolean less(BigDecimal o1, BigDecimal o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.doubleValue() < o2.doubleValue();
	}

	public static boolean notLess(BigDecimal o1, BigDecimal o2) {
		return !less(o1, o2);
	}

	public static boolean lessOrEquals(BigDecimal o1, BigDecimal o2) {
		if (o1 == null || o2 == null) {
			return false;
		}
		return o1.doubleValue() <= o2.doubleValue();
	}

	public static boolean notLessOrEquals(BigDecimal o1, BigDecimal o2) {
		return !lessOrEquals(o1, o2);
	}

	public static BigDecimal limit(BigDecimal o, BigDecimal min,
			BigDecimal max, BigDecimal defaultValue) {
		if (greater(min, max)) {
			BigDecimal temp = min;
			min = max;
			max = temp;
		}
		if (o == null) {
			return filter(defaultValue, min, max);
		} else if (less(o, min)) {
			return filter(defaultValue, min);
		} else if (greater(o, max)) {
			return filter(defaultValue, max);
		} else {
			return o;
		}
	}

	public static BigDecimal limit(BigDecimal o, BigDecimal min, BigDecimal max) {
		return limit(o, min, max, null);
	}

	public static BigDecimal limit(BigDecimal o, BigDecimal minmax) {
		return limit(o, minmax, minmax, null);
	}

	public static BigDecimal max(BigDecimal... os) {
		if (os == null) {
			return null;
		}
		BigDecimal result = null;
		for (BigDecimal o : os) {
			if (result == null || greater(o, result)) {
				result = o;
			}
		}
		return result;
	}

	public static BigDecimal min(BigDecimal... os) {
		if (os == null) {
			return null;
		}
		BigDecimal result = null;
		for (BigDecimal o : os) {
			if (result == null || less(o, result)) {
				result = o;
			}
		}
		return result;
	}

	public static BigDecimal sum(BigDecimal... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Double result = null;
		for (BigDecimal o : os) {
			if (o != null) {
				if (result == null) {
					result = 0D;
				}
				result += o.doubleValue();
			}
		}
		return ObjectUtils.toBigDecimal(result);
	}

	public static BigDecimal add(BigDecimal... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Double result = 0D;
		for (BigDecimal o : os) {
			if (o == null) {
				return null;
			}
			result += o.doubleValue();
		}
		return ObjectUtils.toBigDecimal(result);
	}

	public static BigDecimal subtract(BigDecimal o1, BigDecimal o2) {
		if (ObjectUtils.hasBlank(o1, o2)) {
			return null;
		}
		return ObjectUtils.toBigDecimal(o1.doubleValue() - o2.doubleValue());
	}

	public static BigDecimal multiply(BigDecimal... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Double result = 1D;
		for (BigDecimal o : os) {
			if (o == null) {
				return null;
			}
			result *= o.doubleValue();
		}
		return ObjectUtils.toBigDecimal(result);
	}

	public static BigDecimal divide(BigDecimal o1, BigDecimal o2) {
		if (ObjectUtils.hasBlank(o1, o2) || o2.compareTo(new BigDecimal("0")) == 0) {
			return null;
		}
		return ObjectUtils.toBigDecimal(o1.doubleValue() / o2.doubleValue());
	}

	public static BigDecimal filter(BigDecimal... os) {
		return ObjectUtils.filter(os);
	}

	public static Double round(Double o, Integer scale) {
		if (o == null || o.isNaN() || o.isInfinite()) {
			return null;
		}
		if (o == 0 || scale == null) {
			return o;
		}
		BigDecimal bg = ObjectUtils.toBigDecimal(o);
		return bg.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
	}

	public static Double sum(Object... os) {
		if (ArrayUtils.isEmpty(os)) {
			return null;
		}
		Double result = null;
		for (Object o : os) {
			Double d = ObjectUtils.toDouble(o);
			if (d != null) {
				if (result == null) {
					result = 0D;
				}
				result += d;
			}
		}
		return result;
	}

	public static String toString(Double o, Integer scale) {
		if (o == null || o.isNaN() || o.isInfinite()) {
			return null;
		} else {
			return getDecimalFormat().format(round(o, scale));
		}
	}

	public static String toString(Double o) {
		return toString(o, null);
	}

	public static String toString(BigDecimal o, Integer scale) {
		return toString(ObjectUtils.toDouble(o), scale);
	}

	public static String toString(BigDecimal o) {
		return toString(ObjectUtils.toDouble(o), null);
	}
}